string(LENGTH ${CMAKE_CURRENT_LIST_DIR} dlen)
string(REPLACE ${CMAKE_CURRENT_LIST_DIR} "" root ${CMAKE_CURRENT_LIST_FILE})
string(REPLACE . / root ${root})
string(REPLACE "/cmake" "" root ${ROOT_AT32F403A_407_Firmware_Library}/project/${root})

set(target led_toggle)

add_executable(${target})

file(GLOB src ${root}/src/*.c)

target_sources(${target} PRIVATE ${src})

target_include_directories(${target} PRIVATE
    ${root}/inc
)

target_link_libraries(${target} PRIVATE
    Firmware_Library
    at32f403a_407_board
)

get_property(LDSCRIPT TARGET Firmware_Library PROPERTY LINK_FILE)

set_property(TARGET ${target} PROPERTY SUFFIX ".elf")
target_link_options(${target} PRIVATE
    -Wl,--no-warn-rwx-segments
    -T${LDSCRIPT} -Wl,-Map=${CMAKE_CURRENT_BINARY_DIR}/${target}.map,--cref
)